package com.jxwifi.cloud.quickclean.adapter;

import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.idroid.utils.TextDrawable;
import com.jxwifi.cloud.quickclean.app.StateUtils;
import com.jxwifi.cloud.quickclean.bean.CustomerAddressBean;
import com.jxwifi.cloud.quickclean.bean.TextBean;
import com.jxwifi.cloud.quickclean.R;

import java.util.List;

/**
 * Created by Administrator on 2019/6/14.
 */

public class ClientAddressListAdapter extends BaseQuickAdapter<CustomerAddressBean, BaseViewHolder> {

    public ClientAddressListAdapter(@LayoutRes int layoutResId, @Nullable List data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, CustomerAddressBean item) {
        helper.setText(R.id.tv_address_item_name,item.getProvince()+" "+item.getCity()+" "+item.getArea());
        helper.setText(R.id.tv_address_item_name_details,item.getAddress());
        if (StateUtils.XIAO_QU.equals(item.getTypeCode())){
            helper.setBackgroundRes(R.id.img_address_item_images,R.mipmap.icon_address_type_quarters);
        }else if (StateUtils.XIE_ZI_LOU.equals(item.getTypeCode())){
            helper.setBackgroundRes(R.id.img_address_item_images,R.mipmap.icon_address_type_office);
        }else if (StateUtils.XUE_XIAO.equals(item.getTypeCode())){
            helper.setBackgroundRes(R.id.img_address_item_images,R.mipmap.icon_address_type_school);
        }else if (StateUtils.QI_TA.equals(item.getTypeCode())){
            helper.setBackgroundRes(R.id.img_address_item_images,R.mipmap.icon_address_type_other);
        }
        if (StateUtils.YES.equals(item.getIsDefault())){
            helper.getView(R.id.tv_address_item_selectagreed).setVisibility(View.VISIBLE);
            helper.getView(R.id.tv_address_item_delete).setVisibility(View.INVISIBLE);
        }else{
            helper.getView(R.id.tv_address_item_selectagreed).setVisibility(View.GONE);
            helper.getView(R.id.tv_address_item_delete).setVisibility(View.VISIBLE);
        }
        helper.addOnClickListener(R.id.rel_address_item).addOnClickListener(R.id.tv_address_item_selectagreed)
        .addOnClickListener(R.id.tv_address_item_delete).addOnClickListener(R.id.tv_address_item_edit);

    }
}
